from django.shortcuts import render

# Create your views here.
from django.views import View

from contents.models import ContentCategory
from goods.models import  GoodsChannel
from goods.utils import get_categories


class IndexView(View):
    """首页登陆界面"""
    def get(self, request):
        """广告类数据"""
        contents = {}
        content_cat_qs = ContentCategory.objects.all()

        for content_cat in content_cat_qs:
            contents[content_cat.key] = content_cat.content_set.filter(status=True).order_by('sequence')

        context = {
            "categories": get_categories(),
            "contents":contents
        }

        return render(request,'index.html', context)